Use case: DCACHE maintenance operations in polling mode ¶
Sequence diagram ¶
Code snippet ¶
|
HAL1 |
HAL2 |
|---|---|
/* Init */
HAL_DCACHE_Init(&hdcache);
/* Optional configuration */
HAL_DCACHE_SetReadBurstType(&hdcache, HAL_DCACHE_READ_BURST_WRAP);
HAL_DCACHE_Monitor_Start(&hdcache);
/* Enable DCACHE */
HAL_DCACHE_Enable(&hdcache);
/* Maintenance operations (repeat as needed) */
HAL_DCACHE_Invalidate(&hdcache);
HAL_DCACHE_CleanByAddr(&hdcache, (uint32_t *)buffer, buffer_size);
HAL_DCACHE_InvalidateByAddr(&hdcache, (uint32_t *)buffer, buffer_size);
HAL_DCACHE_CleanInvalidByAddr(&hdcache, (uint32_t *)buffer, buffer_size);
/* Optional monitoring */
(void)HAL_DCACHE_Monitor_GetReadHitValue(&hdcache);
(void)HAL_DCACHE_Monitor_GetReadMissValue(&hdcache);
(void)HAL_DCACHE_Monitor_GetWriteHitValue(&hdcache);
(void)HAL_DCACHE_Monitor_GetWriteMissValue(&hdcache);
HAL_DCACHE_Monitor_Reset(&hdcache);
/* Stop DCACHE */
HAL_DCACHE_Disable(&hdcache);
HAL_DCACHE_DeInit(&hdcache);
|
/* Init */
HAL_DCACHE_Init(&hdcache);
/* Optional configuration */
HAL_DCACHE_SetReadBurstType(&hdcache, HAL_DCACHE_READ_BURST_WRAP);
HAL_DCACHE_ECC_Enable(&hdcache);
HAL_DCACHE_EnableMonitors(&hdcache);
/* Start DCACHE (no interrupt) */
HAL_DCACHE_Start(&hdcache, HAL_DCACHE_IT_NONE);
/* Maintenance operations (repeat as needed) */
HAL_DCACHE_Invalidate(&hdcache);
HAL_DCACHE_CleanByAddr(&hdcache, (uint32_t *)buffer, buffer_size);
HAL_DCACHE_InvalidateByAddr(&hdcache, (uint32_t *)buffer, buffer_size);
HAL_DCACHE_CleanInvalidByAddr(&hdcache, (uint32_t *)buffer, buffer_size);
/* Optional monitoring */
(void)HAL_DCACHE_GetMonitorReadHitValue(&hdcache);
(void)HAL_DCACHE_GetMonitorReadMissValue(&hdcache);
(void)HAL_DCACHE_GetMonitorWriteHitValue(&hdcache);
(void)HAL_DCACHE_GetMonitorWriteMissValue(&hdcache);
HAL_DCACHE_ResetMonitors(&hdcache);
HAL_DCACHE_ECC_Disable(&hdcache);
/* Stop DCACHE */
HAL_DCACHE_Stop(&hdcache);
HAL_DCACHE_DeInit(&hdcache);
|
Key changes ¶
HAL2 uses
HAL_DCACHE_Start()/HAL_DCACHE_Stop()instead ofHAL_DCACHE_Enable()/HAL_DCACHE_Disable().HAL2 adds optional ECC control and monitor configuration APIs.
HAL2 monitor getter and reset APIs are renamed compared to HAL1.
![@startuml
skinparam sequenceMessageAlign center
participant "User\nApplication" as UA
participant "DCACHE\nDriver" as DD
UA->DD : **HAL_DCACHE_Init**
DD-->"Driver RCC" : Compilation switch: clock activation
rnote over DD
Invalidate Operation by Hardware
endrnote
UA <-- DD : return HAL_OK or HAL_INVALID_PARAM
|||
group Loop [Can be repeated]
group Optional
UA->DD : **HAL_DCACHE_SetReadBurstType**
DD --> UA : return HAL_OK
UA->DD : **HAL_DCACHE_Monitor_Start**
DD --> UA : return HAL_OK
|||
end
UA->DD : **HAL_DCACHE_Enable**
DD --> UA : return HAL_OK
group Loop [Can be repeated]
UA->DD : **HAL_DCACHE_Invalidate**,\n**...**\n**HAL_DCACHE_CleanByAddr**,\n**...**\n**HAL_DCACHE_InvalidateByAddr**,\n**...**\n**HAL_DCACHE_CleanInvalidByAddr**,\n**...**
DD --> UA : return HAL_OK, HAL_BUSY, HAL_ERROR
|||
end
group Optional
UA->DD : **HAL_DCACHE_Monitor_GetReadHitValue**, **HAL_DCACHE_Monitor_GetReadMissValue**,\n**HAL_DCACHE_Monitor_GetWriteHitValue**, **HAL_DCACHE_Monitor_GetWriteMissValue**
DD --> UA : Monitor's value
UA->DD : **HAL_DCACHE_Monitor_Reset**
DD --> UA : return HAL_OK
end
|||
UA->DD : **HAL_DCACHE_Disable**
DD --> UA : return HAL_OK
|||
end
|||
UA->DD : **HAL_DCACHE_DeInit**
DD --> UA
@enduml](../../../../../_images/plantuml-83159c5c76894737542676a709c68e0ea6e9dc84.png)
![@startuml
skinparam sequenceMessageAlign center
participant "User\nApplication" as UA
participant "DCACHE\nDriver" as DD
UA->DD : **HAL_DCACHE_Init**
DD-->"Driver RCC" : Compilation switch: clock activation
rnote over DD
Invalidate Operation by Hardware
endrnote
UA <-- DD : return HAL_OK or HAL_INVALID_PARAM
|||
group Loop [Can be repeated]
group Optional
UA->DD : **HAL_DCACHE_SetReadBurstType**
DD --> UA : return HAL_OK
UA->DD : **HAL_DCACHE_ECC_Enable**
note right : * ECC is only available in some stm32 devices\nPlease check the ref-man of your product
DD --> UA : return HAL_OK
UA->DD : **HAL_DCACHE_EnableMonitors**
DD --> UA : return HAL_OK
|||
end
UA->DD : **HAL_DCACHE_Start(&hdcache, HAL_DCACHE_IT_NONE)**
note right : Choose to enable Eviction Clean error interrupt
DD --> UA : return HAL_OK
group Loop [Can be repeated]
UA->DD : **HAL_DCACHE_Invalidate**,\n**...**\n**HAL_DCACHE_CleanByAddr**,\n**...**\n**HAL_DCACHE_InvalidateByAddr**,\n**...**\n**HAL_DCACHE_CleanInvalidByAddr**,\n**...**
DD --> UA : return HAL_OK, HAL_BUSY, HAL_ERROR
|||
end
group Optional
UA->DD : **HAL_DCACHE_GetMonitorReadHitValue**, **HAL_DCACHE_GetMonitorReadMissValue**,\n**HAL_DCACHE_GetMonitorWriteHitValue**, **HAL_DCACHE_GetMonitorWriteMissValue**
DD --> UA : Monitor's value
UA->DD : **HAL_DCACHE_ResetMonitors**
DD --> UA : return HAL_OK
UA->DD : **HAL_DCACHE_ECC_Disable**
note right : * ECC is only available in some stm32 devices\nPlease check the ref-man of your product
DD --> UA : return HAL_OK
end
|||
UA->DD : **HAL_DCACHE_Stop**
DD --> UA : return HAL_OK
|||
end
|||
UA->DD : **HAL_DCACHE_DeInit**
DD --> UA
@enduml](../../../../../_images/plantuml-4898a2ff7a961456bff7b79e01b94cae8986bd30.png)